/*
 * @lc app=leetcode.cn id=1018 lang=javascript
 *
 * [1018] 可被 5 整除的二进制前缀
 */

// @lc code=start
/**
 * @param {number[]} A
 * @return {boolean[]}
 */
var prefixesDivBy5 = function(A) {
    let sum=0
    let arr=[]
    for(let i=0;i<A.length;i++){
        sum=2*sum+A[i]
        sum=sum.toString()
        arr.push(sum[sum.length-1]==0||sum[sum.length-1]==5)
        sum=sum%10
    }
    return arr
};
// @lc code=end
var prefixesDivBy5 = function(A) {
    var remainder = 0;
    return A.map((t) => {
        remainder = (remainder << 1) + t;
        if(remainder >= 5) remainder = remainder - 5;
        return remainder === 0;
    });
}//good
